package com.itsu.spbspider.service.impl;

import com.itsu.spbspider.mapper.CrawlerMapper;
import com.itsu.spbspider.service.Crawler;
import com.itsu.spbspider.util.HttpUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author suben
 * @create time 2020/2/11 19:39
 */
@Service("budejieVideoCrawler")
public class BudejieVideoCrawler implements Crawler {

    @Resource
    private CrawlerMapper crawlerMapper;

    @Override
    public String crawlerData(Integer crawlId) throws Exception {
        com.itsu.spbspider.entity.Crawler crawler = crawlerMapper.selectById(crawlId);
        String method = crawler.getMethod();
        String content = null;
        if (method.toUpperCase().equals("GET")) {
            content = HttpUtil.get(crawler.getUrl());
        } else {
            content = HttpUtil.post(crawler.getUrl());
        }
        return content;
    }
}
